package paginas;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.KeyEvent;
import java.util.ResourceBundle;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import modelUtil.Util;
import usuario.usuarioTO.UsuarioTO;
import util.BotonPersonalizado;
import AccionBoton.AccionFocoCreditos;
import AccionBoton.AccionVolverVisible;

public class MenuConfigPasswordTab extends JPanel{

	
	private static final long serialVersionUID = 1L;
	private JPanel panel1;
	private JPanel panel2;
	private JPanel panel3;
	private JTextField texto1;
	private JTextField texto2;
	private UsuarioTO _user;

	public MenuConfigPasswordTab(UsuarioTO user){
		_user = user;
		this.setPreferredSize(new Dimension(450,450));

		panel1 = new JPanel();
		panel2 = new JPanel();
		panel3 = new JPanel();

		initComponents();

		
	}
	
	private void initComponents(){
		
		GridBagLayout grid2 = new GridBagLayout();
		GridBagConstraints cons = new GridBagConstraints();
		cons.gridheight = 1;
		cons.gridwidth = 1;
		cons.fill = GridBagConstraints.BOTH;
		cons.gridx = 0;
		cons.gridy = 0;
		this.setLayout(grid2);
		crearPanel1();
		grid2.addLayoutComponent(panel1, cons);
		this.add(panel1);
		crearPanel2();
		cons.gridy = 1;
		grid2.addLayoutComponent(panel2, cons);
		this.add(panel2);
		crearPanel3();
		cons.gridy = 2;
		grid2.addLayoutComponent(panel3, cons);
		this.add(panel3);
		
		
	}
	
	private void crearPanel1(){
		
		TitledBorder border = new TitledBorder(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_clave"));
		panel1.setBorder(border);
		panel1.setPreferredSize(new Dimension(440,180));
		FlowLayout grid = new FlowLayout();

		panel1.setLayout(grid);
		grid.setAlignment(FlowLayout.LEFT);
		JLabel titulo = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_admin_clave"));
		titulo.setFont(titulo.getFont().deriveFont((float)18));
		titulo.setHorizontalAlignment(SwingConstants.LEFT);
		//titulo.setPreferredSize(new Dimension(215,150));
		grid.addLayoutComponent("titulo",titulo);
		panel1.add(titulo);
		grid.setHgap(50);
		grid.setVgap(50);
		JLabel clave = new JLabel(_user.getClave());
		clave.setFont(clave.getFont().deriveFont((float)18));

		clave.setHorizontalAlignment(SwingConstants.LEFT);

		grid.addLayoutComponent("clave",clave);
		panel1.add(clave);
		
		

		
	}
	
	private void crearPanel2(){
	 BotonPersonalizado boton1 = Util.BotonImagen(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_cambio_clave"), "");
	 boton1.addActionListener(new AccionVolverVisible(panel3));
	 boton1.setMnemonic(KeyEvent.VK_M);
	 boton1.getLabelTexto().setDisplayedMnemonic(KeyEvent.VK_M);
	 boton1.getLabelTexto().getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_admin") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_cambio_clave"));
	 boton1.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_admin") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_cambio_clave"));
	 boton1.addFocusListener(new AccionFocoCreditos(boton1));
	 panel2.setPreferredSize(new Dimension(430,50));

	 panel2.add(boton1);
		
	}
	
	private void crearPanel3(){
		
		panel3.setPreferredSize(new Dimension(430,180));

		
		TitledBorder border = new TitledBorder(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_cambio_nueva_clave"));
		panel3.setBorder(border);
		GridBagLayout grid = new GridBagLayout();
		GridBagConstraints cons = new GridBagConstraints();
		panel3.setLayout(grid);
		cons.gridheight = 1;
		cons.fill = GridBagConstraints.BOTH;
		cons.gridwidth = 1;
		cons.gridx = 0;
		cons.gridy = 0;
		JLabel titulo = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_clave"));
		grid.addLayoutComponent(titulo, cons);
		panel3.add(titulo);
		
		cons.gridx = 0;
		cons.gridy = 1;
		JLabel titulo2 = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_cambio_nueva_clave"));
		grid.addLayoutComponent(titulo2, cons);
		panel3.add(titulo2);
		
		cons.gridx = 1;
		cons.gridy = 1;
		texto1 = new JTextField();
		texto1.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_textfield_password"));
		texto1.getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_textfield_password"));

		texto1.setPreferredSize(new Dimension(125,25));
		grid.addLayoutComponent(texto1, cons);
		panel3.add(texto1);
		
		
		cons.gridx = 0;
		cons.gridy = 2;
		JLabel titulo3 = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_repetir_clave"));
		grid.addLayoutComponent(titulo3, cons);
		panel3.add(titulo3);
		
		cons.gridx = 1;
		cons.gridy = 2;
		texto2 = new JTextField();
		texto1.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_textfield_repetir_password"));
		texto1.getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_textfield_repetir_password"));
		texto2.setPreferredSize(new Dimension(125,25));

		grid.addLayoutComponent(texto2, cons);
		panel3.add(texto2);
		
		panel3.setVisible(false);

		
	}
	


	public JPanel getPanel3() {
		return panel3;
	}

	public void setPanel3(JPanel panel3) {
		this.panel3 = panel3;
	}

	public JTextField getTexto1() {
		return texto1;
	}

	public void setTexto1(JPasswordField texto1) {
		this.texto1 = texto1;
	}

	public JTextField getTexto2() {
		return texto2;
	}

	public void setTexto2(JTextField texto2) {
		this.texto2 = texto2;
	}

	public UsuarioTO get_user() {
		return _user;
	}

	public void set_user(UsuarioTO user) {
		_user = user;
	}
	
	
	
	
	
}
